package com.heima.article.controller;


import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Api(value = "文章首页",tags = {"ap_article"} )
public class ArticleHomeController {
    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("load")
    @ApiOperation("登录上去首页查询")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        return  ResponseResult.okResult(this.apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_MORE));
    }

    @PostMapping("loadmore")
    @ApiOperation("向下滑动查询更多")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto){
        return  ResponseResult.okResult(this.apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_MORE));
    }

    @PostMapping("loadnew")
    @ApiOperation("向上滑动查询最新")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto){
        return  ResponseResult.okResult(this.apArticleService.loadArticleList(dto, ArticleConstants.LOADTYPE_LOAD_NEW));
    }
}
